package com.nasarius.bank.scorecard.dao.impl;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import org.springframework.stereotype.Repository;

import com.ibatis.sqlmap.client.SqlMapClient;
import com.nasarius.bank.scorecard.dao.BankFactorsDAO;
import com.nasarius.bank.scorecard.domain.BankFactors;
import com.nasarius.bank.scorecard.domain.BankFactorsExample;
@Repository
public class BankFactorsDAOImpl extends SqlMapClientDaoSupport implements BankFactorsDAO {

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table bank_factors
     *
     * @ibatorgenerated Mon Mar 21 00:22:54 IST 2011
     */
	@Autowired
    public BankFactorsDAOImpl(/*@Qualifier("sqlMapClient")*/SqlMapClient sqlMapClient) {
        super();
        setSqlMapClient(sqlMapClient);
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table bank_factors
     *
     * @ibatorgenerated Mon Mar 21 00:22:54 IST 2011
     */
    public int countBankFactorsByExample(BankFactorsExample example) {
        Integer count = (Integer)  getSqlMapClientTemplate().queryForObject("bank_factors.ibatorgenerated_countByExample", example);
        return count;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table bank_factors
     *
     * @ibatorgenerated Mon Mar 21 00:22:54 IST 2011
     */
    public int deleteBankFactorsByExample(BankFactorsExample example) {
        int rows = getSqlMapClientTemplate().delete("bank_factors.ibatorgenerated_deleteByExample", example);
        return rows;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table bank_factors
     *
     * @ibatorgenerated Mon Mar 21 00:22:54 IST 2011
     */
    public int deleteBankFactorsByPrimaryKey(String bankcode, Integer factorid) {
        BankFactors key = new BankFactors();
        key.setBankcode(bankcode);
        key.setFactorid(factorid);
        int rows = getSqlMapClientTemplate().delete("bank_factors.ibatorgenerated_deleteByPrimaryKey", key);
        return rows;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table bank_factors
     *
     * @ibatorgenerated Mon Mar 21 00:22:54 IST 2011
     */
    public void insertBankFactors(BankFactors record) {
        getSqlMapClientTemplate().insert("bank_factors.ibatorgenerated_insert", record);
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table bank_factors
     *
     * @ibatorgenerated Mon Mar 21 00:22:54 IST 2011
     */
    public void insertBankFactorsSelective(BankFactors record) {
        getSqlMapClientTemplate().insert("bank_factors.ibatorgenerated_insertSelective", record);
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table bank_factors
     *
     * @ibatorgenerated Mon Mar 21 00:22:54 IST 2011
     */
    @SuppressWarnings("unchecked")
    public List<BankFactors> selectBankFactorsByExample(BankFactorsExample example) {
        List<BankFactors> list = getSqlMapClientTemplate().queryForList("bank_factors.ibatorgenerated_selectByExample", example);
        return list;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table bank_factors
     *
     * @ibatorgenerated Mon Mar 21 00:22:54 IST 2011
     */
    public BankFactors selectBankFactorsByPrimaryKey(String bankcode, Integer factorid) {
        BankFactors key = new BankFactors();
        key.setBankcode(bankcode);
        key.setFactorid(factorid);
        BankFactors record = (BankFactors) getSqlMapClientTemplate().queryForObject("bank_factors.ibatorgenerated_selectByPrimaryKey", key);
        return record;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table bank_factors
     *
     * @ibatorgenerated Mon Mar 21 00:22:54 IST 2011
     */
    public int updateBankFactorsByExampleSelective(BankFactors record, BankFactorsExample example) {
        UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
        int rows = getSqlMapClientTemplate().update("bank_factors.ibatorgenerated_updateByExampleSelective", parms);
        return rows;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table bank_factors
     *
     * @ibatorgenerated Mon Mar 21 00:22:54 IST 2011
     */
    public int updateBankFactorsByExample(BankFactors record, BankFactorsExample example) {
        UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
        int rows = getSqlMapClientTemplate().update("bank_factors.ibatorgenerated_updateByExample", parms);
        return rows;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table bank_factors
     *
     * @ibatorgenerated Mon Mar 21 00:22:54 IST 2011
     */
    public int updateBankFactorsByPrimaryKeySelective(BankFactors record) {
        int rows = getSqlMapClientTemplate().update("bank_factors.ibatorgenerated_updateByPrimaryKeySelective", record);
        return rows;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table bank_factors
     *
     * @ibatorgenerated Mon Mar 21 00:22:54 IST 2011
     */
    public int updateBankFactorsByPrimaryKey(BankFactors record) {
        int rows = getSqlMapClientTemplate().update("bank_factors.ibatorgenerated_updateByPrimaryKey", record);
        return rows;
    }

    /**
     * This class was generated by Apache iBATIS ibator.
     * This class corresponds to the database table bank_factors
     *
     * @ibatorgenerated Mon Mar 21 00:22:54 IST 2011
     */
    private static class UpdateByExampleParms extends BankFactorsExample {
        private Object record;

        public UpdateByExampleParms(Object record, BankFactorsExample example) {
            super(example);
            this.record = record;
        }

        @SuppressWarnings("unused")
		public Object getRecord() {
            return record;
        }
    }
    
    @SuppressWarnings("unchecked")
    public List<BankFactors> selectBankFactorsByBankCode(String bankCode) {
        List<BankFactors> list = getSqlMapClientTemplate().queryForList("bank_factors.ibatorgenerated_selectByBankCode", bankCode);
        return list;
    }

	@SuppressWarnings("unchecked")
	@Override
	public List<BankFactors> bankFactorsByBankCode(String bankCode,
			Date fromDt, Date toDt) {
		Map<String,Object> criteria= new HashMap<String,Object>();   
		criteria.put("bankCode",bankCode);
		criteria.put("fromDt",fromDt);
		criteria.put("toDt",toDt);
		List<BankFactors> list =(List<BankFactors>) getSqlMapClientTemplate().queryForList("bank_factors.bankFactorsByBankCode", criteria);
	    return list;
	}
	@SuppressWarnings("unchecked")
	@Override
	public List<BankFactors> bankFactorsByBankCodes(List<String> bankCodes,
			Date fromDt, Date toDt) {
		Map<String,Object> criteria= new HashMap<String,Object>();   
		criteria.put("bankCodeList",bankCodes);
		criteria.put("fromdt",fromDt);
		criteria.put("todt",toDt);
		List<BankFactors> list =(List<BankFactors>) getSqlMapClientTemplate().queryForList("bank_factors.bankFactorsByBankCodes", criteria);
	    return list;
	}	

	@SuppressWarnings("unchecked")
	@Override
	public List<BankFactors> bankFactorsByFactor(String factorId, Date fromDt,
			Date toDt) {
		Map<String,Object> criteria= new HashMap<String,Object>();   
		criteria.put("factorId",factorId);
		criteria.put("fromDt",fromDt);
		criteria.put("toDt",toDt);
		List<BankFactors> list =(List<BankFactors>) getSqlMapClientTemplate().queryForList("bank_factors.bankFactorsByFactor", criteria);
	    return list;
	}
    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table bank_factors
     *
     * @ibatorgenerated Mon Mar 21 00:22:54 IST 2011
     */
    public int deleteBankFactorsByFactorID(Integer factorid) {
        BankFactors key = new BankFactors();
        key.setFactorid(factorid);
        int rows = getSqlMapClientTemplate().delete("bank_factors.ibatorgenerated_deleteByFactorID", key);
        return rows;
    }	
}